#ifndef GBWIDGET_H
#define GBWIDGET_H

#include "../src/Util/Vector.h"
#include "..\IRenderable.h"

typedef void (*FuncPtr)();

enum WidgetEvent
{
	WIDGET_EVENT_CLICK = 0,
	WIDGET_EVENT_DBL_CLICK,
	WIDGET_EVENT_MAX
};

enum WidgetType
{
	WIDGET_TYPE_FORM = 1,
	WIDGET_TYPE_LABEL,
	WIDGET_TYPE_BUTTON,
	//WIDGET_TYPE_PROGRESS_BAR,
	WIDGET_TYPE_SCROLL_BAR,
	WIDGET_TYPE_TRACK_BAR,
	//WIDGET_TYPE_CHECK_BOX,
	WIDGET_TYPE_MAX
};

enum AlignType
{
	ALIGN_LEFT = 1,
	ALIGN_CENTER,
	ALIGN_RIGHT
};

class GBForm;
class GBWidget : public IRenderable
{
protected:
	AlignType m_AlignType;
	bool m_bIsAutoSized;
	float m_fSpeed;
	GBWidget* m_pParent;	friend GBForm;	// Only form has access to a parent
	vec2 m_velocity;
	FuncPtr m_pFunctions[WIDGET_EVENT_MAX];

public:
	GBWidget();
	virtual ~GBWidget() { }
	GBWidget(const GBWidget& ref) { Copy(&ref); }

	virtual void Copy(const GBWidget* pRef);
	virtual void Render();
	virtual void Update(const float fTimeStep);

	// Accessors
	float GetSpeed() const { return m_fSpeed; }
	vec2 GetVelocity() const { return m_velocity; }
	bool IsAutoSized() const { return m_bIsAutoSized; }
	AlignType GetAlignment() const { return m_AlignType; }

	// Mutators
	void SetAutoSize(bool bIsAutoSized) { m_bIsAutoSized = bIsAutoSized; }
	void SetAlignment(AlignType align) { m_AlignType = align; }
	void SetSpeed(const float fSpeed) { m_fSpeed = fSpeed; }
	void SetVelocity(const vec2 velocity) { m_velocity = velocity; }

	// Function Pointers
	void SetEventFunction(WidgetEvent _event, const FuncPtr pPtr);

	virtual WidgetType Type() const { return WidgetType(); }
};

// Checks if the mouse is inside a widgets bounding volume
// In: (pWidget): Widget to check the mouse against
// Return: (true) if collision, (false) if no collision
bool MouseToWidget(const GBWidget* pWidget);

#endif